<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>抽奖管理后台</title>
<script type="text/javascript" src="<?php echo site_url('js/jquery.js')?>"></script>
<script type="text/javascript" src="<?php echo site_url('js/checkfrm.js')?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo site_url('js/WdatePicker.js')?>"></script>
<style>
body{background:#F4F4FF; font-size:14px; margin:auto}
.divScroll{     OVERFLOW:auto;
        scrollbar-face-color: #FFFFFF;
        scrollbar-shadow-color: #D2E5F4;
        scrollbar-highlight-color: #D2E5F4;
        scrollbar-3dlight-color: #FFFFFF;
        scrollbar-darkshadow-color: #FFFFFF;
        scrollbar-track-color: #FFFFFF; 
      	scrollbar-arrow-color: #D2E5F4;
	  }
</style>
<script type="text/javascript">
	function openwin(url)
	{
		window.location=''+url+'';
	}
	
	function exchange(id)
	{
		var expressor = $("#expressor_"+id).val();
		var tracenumber = $("#tracenumber_"+id).val();
		if(expressor !='' && tracenumber !=''){
			$.post("<?php echo site_url('adminroot/exchange/sendorder');?>", { id: id, expressor: expressor,tracenumber:tracenumber},
			function(data){
				alert(data);
			});
		}else{
			alert('请填完整填写物流信息!');
		}
	}
</script>
</head>

<body topmargin="0">
<table width="1000px" border="0" cellpadding="0" cellspacing="0" bgcolor="#F4F4FF">
  <tr>
    <td width="235" height="37">&nbsp;</td>
    <td width="759">&nbsp;</td>
  </tr>
  <tr>
    <td height="51">&nbsp;</td>
    <td>
	<form name="sform" method="get" action="exchange">
	<div style="border:#999999; border:solid;border-width:1px;">
	<table width="100%" border="0" cellspacing="1">
      <tr>
        <td width="10%" height="21">开始时间:</td>
        <td width="22%"><input class="Wdate" name="starttime" type="text" onclick="WdatePicker()" /></td>
        <td width="16%">&nbsp;</td>
        <td width="14%">&nbsp;</td>
        <td width="38%">&nbsp;</td>
      </tr>
      <tr>
        <td>结束时间:</td>
        <td><input class="Wdate" name="endtime" type="text" onclick="WdatePicker()" /></td>
        <td align="center">
          <select name="ptype">
		  	<option value="0" <?php if($ptype == 0){?> selected="selected"<?php }?>>全部</option>
		  	<option value="1" <?php if($ptype == 1){?> selected="selected"<?php }?>>实物</option>
			<option value="2" <?php if($ptype == 2){?> selected="selected"<?php }?>>点卡</option>
			<option value="3" <?php if($ptype == 3){?> selected="selected"<?php }?>>金币</option>
          </select>        </td>
        <td>
		  <select name="exchangestate">
		  	<option value="0" <?php if(empty($exchangestate)){?> selected="selected"<?php }?>>全部</option>
			
		  	<option value="1" <?php if($exchangestate == 1){?> selected="selected"<?php }?>>已经申请</option>
			<option value="2" <?php if($exchangestate == 2){?> selected="selected"<?php }?>>已发货</option>
			<option value="3" <?php if($exchangestate == 3){?> selected="selected"<?php }?>>已收货</option>
          </select>		</td>
        <td><input type="submit"  value="提交" /></td>
      </tr>
    </table>
	</div>
	</form>
	</td>
  </tr>
  <tr>
    <td height="485" align="center" valign="top">
<?php require_once 'left.php';?>
    </td>
    <td valign="top" align="center">
	<div align="center" style="width: 90%px; height: 500px; background:#FFFFFF;border:#999999; border:solid;border-width:1px;" class="divScroll">
		 <table width="100%" border="0" cellpadding="0">
		 <?php foreach($list as $key=>$value){?>
          <tr onMouseMove="javascript:this.bgColor='#FCFDEE';"
		onMouseOut="javascript:this.bgColor='#FFFFFF';">
            <td width="100%">
           <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td width="81" height="22"><font color="#FF0000">奖项ID号:</font></td>
            <td width="668" align="left"><?=$value['id']?></td>
          </tr>
		  <tr>
            <td width="81" height="22"><font color="#FF0000">购买时间:</font></td>
            <td width="668" align="left"><?=date('Y-m-d H:i:s',$value['lotterytime'])?></td>
          </tr>
          <tr>
            <td height="22"><font color="#FF0000">活动标题:</font></td>
            <td align="left"><?=$value['infos']?></td>
         </tr>
          <tr>
            <td height="24"><font color="#FF0000">奖品信息:</font></td>
            <td align="left"><?=$value['productname']?></td>
            </tr>
          <tr>
            <td height="25"><font color="#FF0000">中奖人:</font></td>
            <td align="left"><?=$value['txemail']?></td>
            </tr>
           <tr>
            <td height="25"><font color="#FF0000">兑换方式:</font></td>
            <td align="left"><?=getproducttype($value['ptype'])?></td>
          </tr>
           <tr>
             <td height="22"><font color="#FF0000">兑换状态:</font></td>
             <td align="left"><?=getExchangestate($value['exchangestate'])?></td>
           </tr>
		   <?php
		   	if($value['ptype'] == 1){
		   ?>
           <tr>
             <td height="25"><font color="#FF0000">邮寄地址:</font></td>
             <td align="left"><?=$value['address']?></td>
           </tr>
		   <?php
		   	}
		   ?>
		   <?php
		   	if($value['ptype'] == 1 && !empty($value['exchangestate'])){
		   ?>
           <tr>
             <td height="23"><font color="#FF0000">快递公司:</font></td>
             <td align="left">
               <select name="expressor" id="expressor_<?=$value['eid']?>">
			   <option value="0">物流</option>
			   	<option value="1" <?php if($value['expressor'] == 1){?> selected="selected"<?php }?>>FEDEX</option>
				<option value="2" <?php if($value['expressor'] == 2){?> selected="selected"<?php }?>>UPS</option>
				<option value="3" <?php if($value['expressor'] == 3){?> selected="selected"<?php }?>>TNT</option>
               </select>             </td>
           </tr>
           <tr>
             <td height="28"><font color="#FF0000">订单号:</font></td>
             <td align="left">
			 <?php
			 	if($value['exchangestate'] == 2){
			 ?>
               <input type="text" name="tracenumber" id="tracenumber_<?=$value['eid']?>" value="<?=$value['tracenumber']?>" readonly="true"/>       
			   <?php
			   }else{
			   ?>
			    <input type="text" name="tracenumber" id="tracenumber_<?=$value['eid']?>" value="<?=$value['tracenumber']?>"/>       
               <input type="button" name="Submit2" value="提交"  onclick="exchange('<?=$value['eid']?>')"/>
			   <?php
			   }
			   ?>                 </td>
           </tr>
		   <?php
		   }elseif($value['ptype'] == 2){
		   ?>
		    <tr>
             <td height="28"><font color="#FF0000">卡号:</font></td>
             <td align="left">
               <?=$value['cardnum']?>                 </td>
           </tr>
		   <?php
		   }elseif($value['ptype'] == 3){
		   ?>
		   		    <tr>
             <td height="28"><font color="#FF0000">金币:</font></td>
             <td align="left">
               <?=$value['cardnum']?>                </td>
           </tr>
		   <?php
		   }
		   ?>
           <tr>
             <td height="25" colspan="2"><hr/></td>
             </tr>
        </table>
            </td>
          </tr>
             
<?php }?>
                    

                    
        </table>
	<div>
    
    </td>
  </tr>
</table>
</body>
</html>
